import { getAgentTableData, getStationInfo } from '@/api/data2'
export default {
  namespaced: true,
  state: {
    allAgents: [],
    stations: []
  },
  mutations: {
    setAllAgents (state, agents) {
      state.allAgents = agents
    },
    setStations (state, station) {
      state.stations = station
    }
  },
  actions: {
    async getAgentList ({ commit }) {
      const { code, data, desc } = await getAgentTableData()
      if (code == 200) {
        const res = data.datalist || []
        commit('setAllAgents', res)
      }
      return { code, desc }
    },
    async getStationInfo ({ commit }, payload) {
      const { code, data, desc } = await getStationInfo(payload)
      if (code == 200) {
        const res = data.datalist || []
        commit('setStations', res)
      }
      return { code, desc }
    }
  }
}
